package com.haoqizhe.kernel.log.helper;

import com.haoqizhe.kernel.commons.util.SpringContextUtil;
import com.haoqizhe.kernel.log.handler.OperateLogHandler;

/**
 * 获取操作用户账号帮助类
 *
 * @author haoqizhe.li
 * @date 2018/11/18
 **/
public class UserAccountHelper {

    private final OperateLogHandler operateLogHandler;

    private UserAccountHelper() {
        operateLogHandler = SpringContextUtil.getBean(OperateLogHandler.class);
    }

    private static class SingletonInstance {
        private static final UserAccountHelper INSTANCE = new UserAccountHelper();
    }

    public static UserAccountHelper getInstance() {
        return SingletonInstance.INSTANCE;
    }

    public String getUserAccount() {
        if (operateLogHandler != null) {
            return operateLogHandler.getUserAccount();
        }
        return "unknown";
    }
}
